package com.lanhao.aot.kuwo;

import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import cn.hutool.crypto.SecureUtil;
import cn.hutool.http.HttpRequest;

public class MusicKuwoUtil {
	
	private static final Logger LOG = LoggerFactory.getLogger(MusicKuwoUtil.class);

	
	public static void main(String[] args) {
		
		String url = "https://adf.xfyun.cn/kuwo/tranklink";
		String appId = "144950ed";
		String appKey = "56dc4bd99ce295e6b8a11383ce372248";
		String deviceSn = "af577fe4cb7841ce885983cc31a4f43a";
		Long timestamp = System.currentTimeMillis();
		String token = SecureUtil.md5(appId + appKey + timestamp);
		Map<String, Object> requestMap = new HashMap<>();
		requestMap.put("appId", appId);
		requestMap.put("token", token);
		requestMap.put("timestamp", String.valueOf(timestamp));
		requestMap.put("serialNumber", deviceSn);
		requestMap.put("itemid", "118980");
		requestMap.put("format", "24kaac");
		
		String result = HttpRequest.post(url).form(requestMap).execute().body();
		
//		String result = HttpUtil.post(url, request.toJSONString());
		
		LOG.info("调用url={},请求参数requestMap={},返回结果result={}", url, requestMap, result);
	}
}
